from django.db import models

class Goods(models.Model):
    CategoryChoice = (
        (0, "水果"),
        (1, "零食"),
        (2, "饮品"),
        (3, "烟酒")
    )
    name = models.CharField(max_length=64, verbose_name="商品名称", null=False)
    category = models.IntegerField(choices=CategoryChoice, verbose_name="分类")
    price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="价格")
    stock = models.PositiveSmallIntegerField(verbose_name="库存")
    avatar = models.CharField(max_length=256, verbose_name="商品图片")

    class Meta:
        db_table = 'goods'
        verbose_name = '商品'
        verbose_name_plural = verbose_name
        indexes = [
            models.Index(fields=['name', 'id'], name='index_name_and_id')
        ]
